package com.kalvin.kvf.modules.hxy.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kalvin.kvf.common.utils.ShiroKit;
import com.kalvin.kvf.modules.sys.entity.User;
import org.springframework.stereotype.Service;
import com.kalvin.kvf.modules.hxy.entity.Keyword;
import com.kalvin.kvf.modules.hxy.mapper.KeywordMapper;

import java.util.List;

/**
 * <p>
 * 关键字 服务实现类
 * </p>
 * @since 2023-10-28 20:35:19
 */
@Service
public class KeywordServiceImpl extends ServiceImpl<KeywordMapper, Keyword> implements KeywordService {

    @Override
    public Page<Keyword> listKeywordPage(Keyword keyword) {
        User user = ShiroKit.getUser();
        if(!user.getUsername().equals("admin")){
            keyword.setPhone(user.getPhone());
        }
        Page<Keyword> page = new Page<>(keyword.getCurrent(), keyword.getSize());
        List<Keyword> keywords = baseMapper.selectKeywordList(keyword, page);
        return page.setRecords(keywords);
    }

    public List<String> selectKeywords(Long keywordType){
        User user = ShiroKit.getUser();
        String phone = user.getPhone();
        return baseMapper.selectKeywords(phone,keywordType);
    }

}
